import Vue from 'vue'
import Router from 'vue-router'
import App from "../App";

Vue.use(Router);
export const router = new Router({
   mode: 'history',
    //base: '/www/',
    routes: [
        {
            path: '/',
            name: 'weChatHomes',
            title: '数据看板',
            redirect: '/weChatHome',
            component: App,
            children: [
                {
                    path: 'weChatHome',
                    name:'weChatHome',

                    meta: {
                        title: '数据看板',
                        auth: false // 如果此路由需要微信授权请设置为true,默认为false
                    },
                    component: () => import('../goHome/weChatHome.vue'),
                },
                {
                    path: 'iphonScan',
                    name:'iphonScan',

                    meta: {
                        title: '扫码',
                        auth: false // 如果此路由需要微信授权请设置为true,默认为false
                    },
                    component: () => import('../goHome/IphonScan.vue'),
                },
                {
                    path: 'buttonAuth',
                    name:'buttonAuth',

                    meta: {
                        title: '添加菜单',
                        auth: false // 如果此路由需要微信授权请设置为true,默认为false
                    },
                    component: () => import('../goHome/ButtonAuth.vue'),
                },
                {
                    path: 'buttonMenus',
                    name:'buttonMenus',

                    meta: {
                        title: '添加菜单',
                        auth: false // 如果此路由需要微信授权请设置为true,默认为false
                    },
                    component: () => import('../goHome/ButtonMenus.vue'),
                }
            ],

        },
        {
            path: '/ORCode',
            name: 'ORCode',

            keepAlive: true,
            meta: {
                title: '二维码',
                auth: false // 如果此路由需要微信授权请设置为true,默认为false
            },
            component: () => import('../goHome/ORCode.vue'),
        },

        {
            path: '/PCAuth/:clientid/:appName',
            name: 'PCAuth',


            meta: {
                title: 'PC授权页面',
                auth: true // 如果此路由需要微信授权请设置为true,默认为false
            },
            component: () => import('../goHome/PCAuth.vue'),

        },
       {
            path: '/websocket/',
            name: 'websocket',
            title: 'websocket',

            meta: {
                auth: false // 如果此路由需要微信授权请设置为true,默认为false
            },
            component: () => import('../goHome/webTest.vue'),

        },
        {
            path: '/testUp',
            name: 'testUp',
            title: 'testUp',

            meta: {
                auth: false // 如果此路由需要微信授权请设置为true,默认为false
            },
            component: () => import('../test/testUploader.vue'),

        }
]
})
router.beforeEach((to, from, next) => {
    /* 路由发生变化修改页面title */
    if (to.meta.title) {
        document.title = to.meta.title
    }
    next()
})

